package tool

import play.api.data.Forms._
import play.api.data._
import tool.Pojo._

object FormTool {

  val memberForm = Form(
    mapping(
      "account" -> text,
      "password" -> text,
    )(MemberData.apply)(MemberData.unapply)
  )

  val companyMemberForm = Form(
    mapping(
      "account" -> text,
      "password" -> text,
      "companyName" -> text,
    )(CompanyMemberData.apply)(CompanyMemberData.unapply)
  )

  val produceQrcodeForm = Form(
    mapping(
      "num" -> number,
    )(ProduceQrcodeData.apply)(ProduceQrcodeData.unapply)
  )

 val tableForm = Form(
    mapping(
      "name" -> text,
      "tableType" -> text,
      "columnNames" -> list(text),
    )(TableData.apply)(TableData.unapply)
  )

  val changePasswordForm = Form(
    mapping(
      "password" -> text,
      "newPassword" -> text
    )(ChangePasswordData.apply)(ChangePasswordData.unapply)
  )

  val fileNameForm = Form(
    mapping(
      "filename" -> text
    )(FileNameData.apply)(FileNameData.unapply)
  )

  val filePathForm = Form(
    mapping(
      "filePath" -> text
    )(FilePathData.apply)(FilePathData.unapply)
  )

  val nameForm = Form(
    mapping(
      "name" -> text
    )(NameData.apply)(NameData.unapply)
  )

  val originalNameForm = Form(
    mapping(
      "originalName" -> text
    )(OriginalNameData.apply)(OriginalNameData.unapply)
  )

  val tableNameForm = Form(
    mapping(
      "tableName" -> text
    )(TableNameData.apply)(TableNameData.unapply)
  )

  val loadDataForm = Form(
    mapping(
      "tableName" -> text,
      "kind" -> text,
    )(LoadData.apply)(LoadData.unapply)
  )

  val addKitForm = Form(
    mapping(
      "tableName" -> text,
      "configInfo" -> text,
    )(AddKitData.apply)(AddKitData.unapply)
  )

  val updateKitForm = Form(
    mapping(
      "id" -> number,
      "tableName" -> text,
      "name" -> text,
      "config" -> text,
    )(UpdateKitData.apply)(UpdateKitData.unapply)
  )

  val updateRowFilterForm = Form(
    mapping(
      "id" -> number,
      "name" -> text,
      "config" -> text,
    )(UpdateRowFilterData.apply)(UpdateRowFilterData.unapply)
  )

  val updateSelectedColumnForm = Form(
    mapping(
      "tableName" -> text,
      "kitName" -> text,
      "columnNames" -> list(text),
    )(UpdateSelectedColumnData.apply)(UpdateSelectedColumnData.unapply)
  )

 val columnNamesForm = Form(
    mapping(
      "columnNames" -> list(text),
    )(ColumnNamesData.apply)(ColumnNamesData.unapply)
  )

  val updateSearchTypeForm = Form(
    mapping(
      "id" -> number,
      "value" -> text,
    )(UpdateSearchTypeData.apply)(UpdateSearchTypeData.unapply)
  )

  val keysForm = Form(
    mapping(
      "keys" -> list(text),
    )(KeysData.apply)(KeysData.unapply)
  )

  val userNameForm = Form(
    mapping(
      "name" -> text
    )(UserNameData.apply)(UserNameData.unapply)
  )

  val accountForm = Form(
    mapping(
      "account" -> text
    )(AccountData.apply)(AccountData.unapply)
  )

  val idForm = Form(
    mapping(
      "id" -> number
    )(IdData.apply)(IdData.unapply)
  )

  val idStrForm = Form(
    mapping(
      "id" -> text
    )(IdStrData.apply)(IdStrData.unapply)
  )

  val addSampleForm = Form(
    mapping(
      "id" -> text,
      "images" -> list(text)
    )(AddSampleData.apply)(AddSampleData.unapply)
  )

  val workflowForm = Form(
    mapping(
      "id" -> text,
      "progress" -> text,
      "sampleInfo" -> text,
    )(WorkflowData.apply)(WorkflowData.unapply)
  )

  val phoneForm = Form(
    mapping(
      "phone" -> text
    )(PhoneData.apply)(PhoneData.unapply)
  )

  val idsForm = Form(
    mapping(
      "ids" -> list(number)
    )(IdsData.apply)(IdsData.unapply)
  )

  val idStrsForm = Form(
    mapping(
      "ids" -> list(text)
    )(IdStrsData.apply)(IdStrsData.unapply)
  )

  val pageForm = Form(
    mapping(
      "limit" -> number,
      "offset" -> number,
    )(PageData.apply)(PageData.unapply)
  )

}
